package services;

import domain.entities.ContactPerson;
import domain.entities.ContactPersonDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ContactPersonService {

    private ContactPersonDAO contactPersonDAO;

    public ContactPersonService() {
    }

    @Autowired
    public ContactPersonService(ContactPersonDAO contactPersonDAO){
        this.contactPersonDAO = contactPersonDAO;
    }

    public ContactPerson findById(int id){
        return contactPersonDAO.findById(id);
    }

    public void delete(ContactPerson contactPerson){
        contactPersonDAO.delete(contactPersonDAO.findById(contactPerson.getId()));
    }

    public void save(ContactPerson contactPerson){
        contactPersonDAO.attachDirty(contactPerson);
    }

}
